package com.example.myapplication;

import android.app.Application;

import com.example.myapplication.net.Common;
import com.example.myapplication.net.ServerReleaseAddress;
import com.example.myapplication.net.ServerTestAddress;
import com.example.myapplication.utils.SharedPreferenceUtil;
import com.hjq.toast.ToastUtils;
import com.lzy.okgo.OkGo;

import org.conscrypt.Conscrypt;

import java.security.Security;


public class MyAPP extends Application {

    private static MyAPP myApplication;



    public static MyAPP getInstance() {
        return myApplication;
    }
    private static final String DATABASE_NAME = "greendao.db";
    @Override
    public void onCreate() {
        super.onCreate();
        /**
         * 引入bugly
         * bugly主动上报：
         * CrashReport.postCatchedException(thr);  // bugly会将这个throwable上报
         * */
        myApplication = this;
        ToastUtils.init(this);
        initAddress();
        // 注册 Conscrypt 作为安全提供程序
        Security.insertProviderAt(Conscrypt.newProvider(), 1);

        OkGo.getInstance().init(this);
    }

    private void initAddress() {
        int type =  BuildConfig.ENV_TYPE;
        //正式环境
        if (type == 3){
            //开发环境默认是打开的
            Common.initAddress(ServerReleaseAddress.BaseUrl);
        }else {
            //开发和测试环境
            Common.initAddress(ServerTestAddress.BaseUrl);
        }
    }



}
